package hutool;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.extension.api.R;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.util.Arrays;

/**
 * 字符串操作测试
 *
 * @author zhoujie
 * @date 2020-07-14
 */
public class StrTest {
    @Test
    public void test01(){
        System.out.println(StrUtil.format("这是一个字符串{}","str"));
        System.out.println(StrUtil.format("是否为无效字符串：{}",StrUtil.isNullOrUndefined("undefined")));
        System.out.println("驼峰转下划线userName->"+StrUtil.toUnderlineCase("userName"));
        System.out.println("下划线转驼峰user_name->"+StrUtil.toCamelCase("user_name"));
        System.out.println(StrUtil.format("根据方法名转属性名称getUserName—->{}",StrUtil.getGeneralField("getUserName")));
        System.out.println(StrUtil.format("补全字符长度1->{}",StrUtil.padPre("1",3,"0")));
        System.out.println(StrUtil.format("补全字符长度1000->{}",StrUtil.padPre("1000",3,"0")));
        System.out.println(StrUtil.format("等分切割123456->{}", Convert.toStr(StrUtil.cut("123456",2))));
        System.out.println(StrUtil.format("比较两个字符串的相似度，1234，1243-> {}",StrUtil.similar("1234","1243")));
        System.out.println(StrUtil.format("uuid，-> {}",StrUtil.replace(StrUtil.uuid(),"-","") ));
        System.out.println(StrUtil.format("连接字符串1,2,3,null-> {}",StrUtil.concat(true,"1","2",null,"3")));


        System.out.println("日喀则电信中心厅"=="日喀则电信中心厅");
        System.out.println(SecureUtil.md5("日喀则电信中心厅"));
        String url="https://topic.vivo.com.cn/experience/TP2m8766r24860/index.html";
        System.out.println(Arrays.toString(StringUtils.split(url,"/")) );
    }
}
